<?php
use_helper('I18N');
/** @var Array of menu items */ $items = $sf_data->getRaw('items');
/** @var Array of categories, each containing an array of menu items and settings */ $categories = $sf_data->getRaw('categories');
?>


<?php if (count($items)): ?>
<ul id="jsddm" class="adminheader ui-widget ui-helper-clearfix">
        <?php if (sfJqueryDash::hasItemsMenu($items)): ?>
    <li><a href="#">Menu</a>
        <ul id="" class="adminheader ui-widget ui-helper-clearfix">
                    <?php include_partial('sfJqueryDash/menu_list', array('items' => $items, 'items_in_menu' => true)); ?>
        </ul>
    </li>
        <?php  endif; ?>
        <?php include_partial('sfJqueryDash/menu_list', array('items' => $items, 'items_in_menu' => false)); ?>
</ul>
<?php endif; ?>
<?php if (count($categories)): ?>
    <?php
    $i = 0;
    foreach ($categories as $name => $category):
        ?>
            <?php
            if (sfJqueryDash::hasPermission($category, $sf_user)):
                if (sfJqueryDash::hasItemsMenu($category['items'])): ?>
<ul id="jsddm">
    <li id="topmenu<?php echo ++$i ?>" class="topheader ui-allow-hover ui-corner-all ui-widget-header ui-helper-clearfix"><a href="#"><?php echo isset($category['name']) ? $category['name'] : $name ?></a>
                        <?php
//    foreach ($categories as $name => $category)
//    {
                        ?>
            <ul class="ui-widget ui-helper-clearfix">
                                <?php include_partial('sfJqueryDash/menu_list', array('items' => $category['items'], 'items_in_menu' => true)) ?>
            </ul>
    </li>        
</ul><?php
//    }
                endif;
            endif;
            ?>
    <?php
    endforeach;
    ?>
<?php elseif (!count($items)):
    echo __('sfJqueryDashPlugin is not configured.  Please see the %documentation_link%.', array('%documentation_link%'=>link_to(__('documentation', null, 'sf_admin_dash'), 'http://www.symfony-project.org/plugins/sfJqueryDashPlugin?tab=plugin_readme', array('title' => __('documentation', null, 'sf_admin_dash')))), 'sf_admin_dash');
endif;
?>